using System;
using System.Collections.Generic;
using System.Text;
using XNALibrary.PostProcessing;

namespace Test1
{
    public class FilterStateManager
    {
        private List<FilterState> filterStates;
        private int index;

        public List<FilterState> FilterStates
        {
            get { return filterStates; }
            set { filterStates = value; }
        }

        public FilterStateManager()
        {
            filterStates = new List<FilterState>();
            index = 0;
        }

        public void NextFilter(PostProcessingManager post)
        {
            if (filterStates.Count > 1)
            {
                index = (index + 1) % filterStates.Count;
                post.Filters.Clear();
                foreach (BaseFilter filter in filterStates[index].Filters)
                    post.AddFilter(filter);
            }
            else if (filterStates.Count == 1)
            {
                post.Filters.Clear();
                foreach (BaseFilter filter in filterStates[0].Filters)
                    post.AddFilter(filter);
            }
        }

        public void PreviousFilter(PostProcessingManager post)
        {
            if (filterStates.Count > 1)
            {
                index--;
                if (index < 0)
                    index = filterStates.Count - 1;
                post.Filters.Clear();
                foreach (BaseFilter filter in filterStates[index].Filters)
                    post.AddFilter(filter);
            }
            else if (filterStates.Count == 1)
            {
                post.Filters.Clear();
                foreach (BaseFilter filter in filterStates[0].Filters)
                    post.AddFilter(filter);
            }
        }
    }
}
